<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>jTranslate API test</title>
  <script type="text/javascript">
   window.translateAPIkey = 'AIzaSyDDwzXvooGYK0rlcSFOmzu80cuU3lgs4Ok';
   window.translateProxyUrl = 'jTranslate.php';
   function init(){
    window.google.language.translate({text:[document.getElementById('testString').innerHTML,'How are you today?','I love you!'],type:'text'},'en','de',callback);
    window.translateControl = new window.google.language.translateControl('controlContainer','controlMaster');
   }
   function callback(response){
    var translations = response.data.translations;
    try{
     document.getElementById('translatedTestString').innerHTML = translations[0].translatedText;
    }catch(err){
     alert('there was a problem translating');
     window.problematicResponse = response;
    }
    for(var i=1; i<translations.length; i++){
     var el = document.createElement('div');
     el.innerHTML = translations[i].translatedText;
     document.getElementsByTagName('body')[0].appendChild(el);
    }
   }
   window.onload = init;
  </script>
  <script type="text/javascript" src="jTranslate.min.js"></script>
 </head>
 <body>
  <div id="testString">Hello, world!</div>
  <div id="translatedTestString">Loading...</div>
  <div id="translateControl"></div>
  
  <div id="controlContainer"></div>
  <div id="controlMaster">This is Captain Jean-Luc Picard of the Federation starship Enterprise. You have committed acts of aggression against the United Federation of Planets. If you do not withdraw, we will engage you.</div>
 </body>
</html>